package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author huan
 * @serial 每天一百行, 致敬未来的自己
 * @Description
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词管理API", tags = "敏感词管理API")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService sensitiveService;

    @PostMapping("/list")
    @ApiOperation("敏感词分页列表查询")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDto dto) {
        return sensitiveService.findByNameAndPage(dto);
    }
    @PostMapping("/save")
    @ApiOperation("新增敏感词信息")
    public ResponseResult save(@RequestBody AdSensitive adSensitive) {
        return sensitiveService.insert(adSensitive);
    }
    @PostMapping("/update")
    @ApiOperation("修改敏感词信息")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return sensitiveService.update(adSensitive);
    }
    @DeleteMapping("/del/{id}")
    @ApiOperation("根据id删除敏感词")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return sensitiveService.deleteById(id);
    }

    @PostMapping("/sensitives")
    @ApiOperation("查询敏感词内容list")
    public ResponseResult<List<String>> selectAllSensitive() {
        return sensitiveService.selectAll();
    }
}
